

<!-- 店铺搜索 -->
<template>
	<view>
		<!-- header部分 -->
		<view class="bg-Container header-height">
			<view class="header-bg"></view>
			
			<!-- 导航栏 -->
			<view class="header-Container header-height">
				<view class="content2">
					
					<image :src="icon.return" class="return" @click="gotoNavBack()"></image>
					
					<!-- 模糊搜索 -->
					<view class="search-input">
						<image :src="icon.search" mode="widthFix"></image>
						<input focus confirm-type="search" @confirm="confirmSearchHandler()" placeholder-class="placeholder" placeholder="搜索店内商品" v-model="search"/>
					</view>
					
					<view @click="toggleMenuListHandler()" class="msgCenter-Container">
						<image class="menu" :src="icon.menuBtn_white"></image>
						<view v-if="noticeTipCount" class="msgCount">
							{{noticeTipCount > 99 ? '99+' : noticeTipCount}}
						</view>
					</view>
				</view>
			</view>
		</view>	
		

		<!-- 商品列表 -->
		<!-- 筛选框 -->
		<view class="filterBar headerNext">
			<navbar @getAction="tabClick"></navbar>
		</view>
		
		<!-- 大图列表 -->
		<view class="good_list" v-if="listType==0">
			<goodList v-if="goodsList && goodsList.length" :list='goodsList'></goodList>
			<g-empty v-else></g-empty>
		</view>
		
		<!-- 横向列表 -->
		<view class="good_list2" v-else>
			<goodListtransverse v-if="goodsList && goodsList.length" :list='goodsList'></goodListtransverse>
			<g-empty v-else></g-empty>
		</view>
		
		
		<!-- 详情菜单 -->
		<view v-if="showDetailMenu" @click="toggleMenuListHandler()" class="detailMenu-Container">
			<detailMenu></detailMenu>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	
	import goodList from '@/components/goodList/goodList';
	import goodListtransverse from '@/components/goodList/goodList-transverse';
	import navbar from '@/components/navbar/navbar';
	import detailMenu from "@/components/detailMenu/detailMenu";
	
	export default {
		components: {
			goodList,
			navbar,
			goodListtransverse,
			detailMenu
		},
		computed: {
			...mapState(['imgSite', 'hasLogin'])
		},
		data() {
			return {
				icon: {
					delete: '/static/images/list/delete.png',
					return: '/static/images/common/return-black.png',
					headerBg: '/static/images/common/header.png',
					search: '/static/images/index/search.png',
					menuBtn_white: "/static/images/common/msg-center-black.png",
				},
				
				noticeTipCount: 0,
				
				//详情菜单
				showDetailMenu: false,
				
				listType: 0,
				sortType: 0,
				goodsList: [],
				
				
				//查询条件
				search: '',
				vendorId: "",
				goodsCategoryFirst: "",
				goodsCategoryThird: "",
				
				
				//分页相关
				pageNum: 1,
				pageSize: 10
			};
		},
		onLoad(options) {
			
			this.vendorId = options.vendorId || "";
			this.goodsCategoryFirst = options.goodsCategoryFirst || "";
			this.goodsCategoryThird = options.goodsCategoryThird || "";
			
			this.pageNum = 1;
			this.getSearchGoodsList();
		},
		onShow() {
			
			if (this.hasLogin) {
				
				let that = this;
				this.$api.globalUtil.requestAjax({
					url: '/customerNoticeApi/customerNoticeUnreadCountApi',
					method: 'POST',
					data: {
						cnType: "",
						cnStatus: '0'
					},
					success: function(res) {
						that.noticeTipCount = res.data.response;
					}
				});
			}
			
			this.showDetailMenu = false;
		},
		methods: {
			
			//返回
			gotoNavBack() {
				uni.navigateBack();
			},
			
			//详情菜单
			toggleMenuListHandler() {
				this.showDetailMenu = !this.showDetailMenu;
			},
			
			//搜索处理
			confirmSearchHandler() {
				this.pageNum = 1;
				this.getSearchGoodsList(this.search);
			},
			
			
			//列表筛选条件
			tabClick(params) {
				
				if(params.listFlag) {
					this.listType = params.listType;
				}else if(params.sortFlag) {

					if(params.sortType == 3) {
						this.sortType = params.priceSort;
					}else {
						this.sortType = params.sortType;
					}
					
					this.pageNum = 1;
					this.getSearchGoodsList();
				}
			},
				
			
			//商品列表
			getSearchGoodsList(searchByKeyword) {
				
				var that = this;
				that.$api.globalUtil.requestAjax({
					url: '/vendorApi/findVendorGoodsByVendorIdApi',
					method: "POST",
					data: {
						vendorId: that.vendorId,
						search: that.search,
						isSearch: ((that.goodsCategoryFirst || that.goodsCategoryThird) ? false : true),
						pageNum: that.pageNum, //页码
						pageSize: that.pageSize,//显示条数
						sort: that.sortType, //综合排序:null 销量排序:1 新品排序:2 价格ASC:3 价格DESC:4
						goodsCategoryFirst: that.goodsCategoryFirst,
						goodsCategoryThird: that.goodsCategoryThird
					},
					success: function(res) {
						if(res.data.success) {
							
							that.goodsList = [];
							if(res.data.response.results.length) {
								if(that.pageNum == 1) {
									that.goodsList = res.data.response.results;
								}else {
									that.goodsList = that.goodsList.concat(res.data.response.results);
								}
							}else {
								that.$api.msg("没有更多数据！");
							}
						}
					}
				});
			}
		}
	};
</script>

<style lang="scss">
	
	/* header */
	.bg-Container {
		width: 100%;
	    z-index: 10;
		
		.header-bg {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 100%;
			background-color: #FFFFFF;
		}
	
		.header-Container {
			width: 100%;
			height: 176rpx;
	
			.content2 {
				display: flex;
				align-items: center;
				justify-content: space-between;
				position: absolute;
				bottom: 0;
				padding: 0 46rpx 0 0;
				width: 100%;
				height: 88rpx;
				
				.return {
					width: 44rpx;
					height: 44rpx;
					margin-left: 19rpx;
				}
	
				.search-input {
					position: relative;
					margin-left: 40rpx;
					width: 540rpx;
					border-radius: 28px;
					border: 1rpx solid rgba(0,0,0,0.2);
	
					image {
						position: absolute;
						left: 30rpx;
						top: 16rpx;
						width: 26rpx;
						height: 26rpx;
					}
					input {
						box-sizing: border-box;
						padding-left: 74rpx;
						height: 56rpx;
						line-height: 28rpx;
						font-weight: 400;
						font-family: MicrosoftYaHei;
						font-size: 28rpx;
						border-radius: 28rpx;
						background-color: #ffffff;
					}
					.placeholder {
						font-weight: 400;
						font-family: MicrosoftYaHei;
						font-size: 28rpx;
						color: #999999;
					}
				}
	
				.btn-icon {
					width: 50rpx;
					height: 51rpx;
					margin-left: 35rpx;
					font-size: 25rpx;
					display: flex;
					align-items: center;
					justify-content: center;
				}
			}
		}
	}
	
	.msgCenter-Container {
		display: flex;
		align-items: center;
		margin-left: 34rpx;
		height: 44rpx;
		
		.menu {
			width: 40rpx;
			height: 40rpx;
		}
		.msgCount {
			position: absolute;
			bottom: 50rpx;
			right: 32rpx;
			min-width: 26rpx;
			width: auto;
			height:26rpx;
			line-height: 26rpx;
			text-align: center;
			font-size:20rpx;
			font-family:PingFang SC;
			font-weight:bold;
			color:rgba(219,13,83,1);
			background:rgba(255,255,255,1);
			box-shadow:0px 1rpx 4rpx 0px rgba(68,68,68,0.2);
			border-radius:26rpx;
		}
	}

	// 商品列表
	/deep/.list-pages {
		padding: 0 30rpx;
		
		.list-block {
			margin-bottom: 30rpx;
			width: 336rpx;
			box-shadow: 0 2rpx 10rpx 0 rgba(103,103,103,0.1);
			border-radius:10rpx;
			
			.list-poster {
				width: 336rpx;
				height: 336rpx;
			}
		}
	}
	.good_list2{
		width: 100%;
		background-color: white;
	}

	// 搜索框
	.search-block {
		width: 100%;
		height: 100vh;
		overflow: hidden;
		background-color: white;
		top: 176rpx;
		z-index: 20;
		border-radius:20rpx 20rpx 0px 0px;

		.search-title {
			margin: 23rpx 0 0 29rpx;
			font-size: 28rpx;
			font-weight: bold;

			.search-img {
				position: absolute;
				height: 31rpx;
				width: 31rpx;
				right: 30rpx;
			}
		}

		.search-message {
			margin-top: 26rpx;
			display: flex;
			width: 718rpx;
			flex-wrap: wrap;
			line-height: 63rpx;
			margin-left: 29rpx;

			view {
				flex-shrink: 0;
				color: #666;
				padding: 0 22rpx 0 22rpx;
				background-color: #eeeeee;
				border-radius: 27rpx;
				font-size: 23rpx;
				height: 53rpx;
				margin-right: 18rpx;
				margin-top: 18rpx;
				display: flex;
				justify-content: center;
				align-items: center;
			}

			view:last-child {
				margin-right: 0;
			}
		}
	}
	
	.placeholder {
		font-size: 26rpx;
		color: #999999;
	}
</style>



